package cn.stylefeng.guns.rabbitmq.service.impl;

import cn.stylefeng.guns.rabbitmq.config.RenStatusMsg;
import cn.stylefeng.guns.rabbitmq.model.ResultParam;
import cn.stylefeng.guns.rabbitmq.service.IBatchCardService;
import cn.stylefeng.guns.rabbitmq.service.ICardService;
import cn.stylefeng.guns.rabbitmq.util.DES3Util;
import cn.stylefeng.guns.rabbitmq.util.EncryptionUtil;
import cn.stylefeng.guns.rabbitmq.util.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class BatchCardServiceImpl implements IBatchCardService {

    @Value("${order.createOrder}")
    private String createOrder;

    private final String sign = "pmy2019app";

    /**
     * 发送
     *
     * @param object
     */
    @Override
    public boolean sendBatchCardSubmit(JSONObject object) {
        try {
            object.put("apiSign", sign);
            String result = HttpUtil.sendPostJson(createOrder, object.toJSONString(), "utf-8");
            JSONObject resJson = JSONObject.parseObject(result);
            if (resJson.getBoolean("success")) {
                return true;
            }
        } catch (IOException e) {
            log.error("队列提交至主模块处理订单出错");
            e.printStackTrace();
            return false;
        }
        return false;
    }
}
